package Map;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class MapTest {
    public static void main(String[] args) {
        HashMap<String, Student> map = new HashMap<>();
       Student s1 = new Student("2210","张三",18,96);
       Student s2 = new Student("2211","张四",19,99);
       Student s3 = new Student("2212","张五",20,18);
       map.put(s1.getId(),s1);//学号自动获取
       map.put(s2.getId(),s2);
       map.put(s3.getId(),s3);
        Set<Map.Entry<String, Student>> entrySet = map.entrySet();
        boolean falg=false;
        for (Map.Entry<String, Student>entry:entrySet) {
            if (entry.getValue().getName().equals("张三")){
                falg=true;
                System.out.println(entry.getKey()+":"+entry.getValue());
                entry.getValue().setGrades(100);
                System.out.println(entry.getValue());
            }
        }
            if (false==false){
                System.out.println("查无此人");
            }
    }
}
class Student{
    private String id;
    private String name;
    private int age;
    private double grades;

    public Student(String id, String name, int age, double grades) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.grades = grades;
    }

    public Student() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getGrades() {
        return grades;
    }

    public void setGrades(double grades) {
        this.grades = grades;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", grades=" + grades +
                '}';
    }


}
